// 提供商品相关的API函数
import request from '@/utils/request'

/**
 * 获取商品详情
 * @params {String} id -商品ID
 */
export const findGoods = (id) => {
  return request('/goods', 'get', { id })
}

/***
 * 获取商品相关推荐
 * @param id
 * @param limit
 * @returns {*|AxiosPromise}
 */
export const findRelGoods = (id, limit = 16) => {
  return request('/goods/relevant', 'get', {
    id,
    limit
  })
}

/**
 * 获取热搜榜
 * @param id
 * @param limit
 * @param type
 */
export const findGoodsHot = ({
  id,
  limit = 3,
  type = 1
}) => {
  return request('/goods/hot', 'get', {
    id,
    limit,
    type
  })
}

/**
 * 查询商品评价信息
 * @param id
 * @returns {*|AxiosPromise}
 */
export const findGoodsCommentInfo = (id) => {
  // axios 遇见 http https 开头的地址，不会加上基准地址
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`, 'get')
}

/**
 * 查询商品列表
 * @param id
 * @param params
 * @returns {*|AxiosPromise}
 */
export const findGoodsCommentList = (id, params) => {
  // axios 遇见 http https 开头的地址，不会加上基准地址
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`, 'get', params)
}
